package controlller;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import comm.DataManagement;
import fxManager.FXManager;
import javafx.event.ActionEvent;
import javafx.fxml.Initializable;
import javafx.scene.control.MenuBar;
import javafx.stage.FileChooser;

public class MenuController extends MenuBar implements Initializable{

	@Override
	public void initialize(URL url, ResourceBundle source) {
		ControllerManager.add("bar", this);
	}

	public void importHandler(ActionEvent e) {
		FileChooser chooser=new FileChooser();
		
		File selected=chooser.showOpenDialog(FXManager.getStage());
		if (selected!=null) {
			String url=selected.getAbsolutePath();
			try {
				DataManagement.loadUsers(url);
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			TableViewController tableController=ControllerManager.getTable();
			tableController.insertIntoTable();
		}
	}

}
